home *** CD-ROM | disk | FTP | other *** search
/ 3D Games - Real-time Rend…ng & Software Technology / 3D Games - Real-time Rendering & Software Technology.iso / flysdk / plugin / lights / spot_light.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-27  |  940 b   |  49 lines

  1. #include "../../lib/Fly3D.h"
  2. #include "lights.h"
  3.  
  4. void spot_light::reposition(bsp_object *obj)
  5. {
  6.     if (directx->mpmode!=FLYMP_SERVER && l)
  7.     {
  8.         vector p1,p2;
  9.         p1 = obj->pos;
  10.         p2 = p1 - obj->Z*maxdist;
  11.         flyengine->excludecollision=obj;
  12.         if (flyengine->collision_bsp(flyengine->bsp,p1,p2))
  13.         {
  14.             flyengine->excludecollision=0;
  15.             if (flyengine->hitobj)
  16.             {
  17.             l->color=color*(1.0f - (flyengine->hitip-p1).length()/maxdist);
  18.             l->pos=flyengine->hitip;
  19.             l->step(0);
  20.             }
  21.         }
  22.         else flyengine->excludecollision=0;
  23.     }
  24. }
  25.  
  26. int spot_light::get_custom_param_desc(int i,param_desc *pd)
  27. {
  28.     if (pd!=0)
  29.     switch(i)
  30.     {
  31.         case 0:
  32.             pd->type='f';
  33.             pd->data=&maxdist;
  34.             strcpy(pd->name,"maxdist");
  35.             break;
  36.         case 1:
  37.             pd->type='c';
  38.             pd->data=&color;
  39.             strcpy(pd->name,"color");
  40.             break;
  41.         case 2:
  42.             pd->type=TYPE_LIGHT;
  43.             pd->data=&l;
  44.             strcpy(pd->name,"light");
  45.             break;
  46.     }
  47.     return 3;
  48. }
  49.